home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: artemis.sto.fdata.se!news
- From: Niklas Mellin <niklas.mellin@sto.fdata.se>
- Subject: Re: What are the differences between structures and classes in C++ ?
- Sender: news@artemis.sto.fdata.se (UseNet NetNews)
- Message-ID: <316A7639.3383@sto.fdata.se>
- Date: Tue, 9 Apr 1996 14:37:45 GMT
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
- References: <4k5m65$av@hpscit.sc.hp.com>
- Mime-Version: 1.0
- X-Mailer: Mozilla 2.0 (WinNT; I)
- Organization: WM-data F÷rsvarsdata AB, Sweden
-
- Raghuveera Ravinutala wrote:
- >
- > Hi,
- > Please mail me the differences between structures and classes in C++.
- > Raghu.
-
- This is an interesting thread. I have so far read 11 answers to the original
- question, and nobody came up with the correct answer, even though it is in
- the FAQ:
-
- |Q130: What's the difference between the keywords struct and class?
- |
- |The members and base classes of a struct are public by default, while in class,
- ^^^^^^^^^^^^^^^^
- |they default to private. Note: you should make your base classes EXPLICITLY
- |public, private, or protected, rather than relying on the defaults.
- |
- |"struct" and "class" are otherwise functionally equivalent.
-
- This means that:
-
- class X: BaseX
- {
- int x;
- };
-
- is equivalent to:
-
- struct X: private BaseX
- {
- private:
- int x;
- };
-
- and that:
- struct Y: BaseY
- {
- int y;
- };
-
- is equivalent to:
- class Y: public BaseY
- {
- public:
- int y;
- };
-
- ---
- Niklas Mellin
-
- PS. The FAQ can be found at: ftp://rtfm.mit.edu/pub/usenet/comp.lang.c++
-